package cn.vconinfo.app.enums;

/**
 * @author vconinfo
 * @createdOn 2019/07/22
 * @description:业务码
 */
public class BusinessService {
    public enum SystemCode {
        /**
         * 登录异常码
         */
        LOGIN_SUCCESS("登录成功"), LOGOUT_SUCCESS("登出成功"), NEED_LOGIN_PARAM("登录参数不存在"), NEED_USERNAME("用户名不存在"), NEED_PWD("密码不存在"), INVALID_USERNAME_PWD("用户名或密码错误"), NO_PERMISSION("无权限"), USER_REPEAT("用户重复"), UNKNOWN_USER("未知用户"),
        ;
        private String name;

        SystemCode(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }
    }

    public enum AuthCode {
        /**
         * 角色
         */
        ADMIN("admin", "管理员"), OPERATOR("operator", "操作员"),
        ;

        AuthCode(String code, String name) {
            this.code = code;
            this.name = name;
        }

        private String code;
        private String name;

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 接口调用来源
     */
    public enum RequestResource {
        /**
         * 来源
         */
        REQ_PLATFORM(0, "platform", "平台"),
        REQ_TEST(1, "test", "测试"),
        REQ_THIRD(2, "third", "三方调用"),
        ;
        RequestResource(int key, String code, String name) {
            this.key = key;
            this.code = code;
            this.name = name;
        }
        private int key;
        private String code;
        private String name;

        public int getKey() {
            return key;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 通用业务编码
     */
    public enum CommonBusinessCode {
        // 请求结果
        REQ_SUCCESS(0, "SUCCESS", "成功"),
        REQ_FAILURE(400, "FAIL", "失败"),
        REQ_ERROR(500, "ERROR", "异常"),
        REQ_UNKNOWN_QUERY_RESULT(1001, "UNKNOWN_QUERY_RESULT", "未知查询结果"),
        REQ_INFO_REFRESH(1002, "INFO_REFRESH", "信息已更新，当前操作无效，请刷新重试"),
        REQ_UNKNOWN_TYPE(1003, "UNKNOWN_TYPE", "未知类型"),

        REQ_SEARCH_SUCCESS(0, "REQ_SEARCH_SUCCESS", "查询成功"),
        REQ_SEARCH_FAILURE(400, "REQ_SEARCH_FAILURE", "查询失败"),
        REQ_INSERT_SUCCESS(0, "REQ_INSERT_SUCCESS", "新增成功"),
        REQ_INSERT_FAILURE(400, "REQ_INSERT_FAILURE", "新增失败"),
        REQ_UPDATE_SUCCESS(0, "REQ_UPDATE_SUCCESS", "修改成功"),
        REQ_UPDATE_FAILURE(400, "REQ_UPDATE_FAILURE", "修改失败"),
        REQ_DELETE_SUCCESS(0, "REQ_DELETE_SUCCESS", "删除成功"),
        REQ_DELETE_FAILURE(400, "REQ_DELETE_FAILURE", "删除失败"),


        // 数据库字段校验
        CHECK_NEED_DATA(3002, "NEED_DATA", "必要参数未传"),
        CHECK_NEED_ID(809, "NEED_ID", "缺少ID"),
        CHECK_NEED_VERSION(3003, "NEED_VERSION", "缺少版本号"),
        CHECK_MAXLENGTH_BEYOND(3008, "MAXLENGTH_BEYOND", "超过最大长度"),
        CHECK_COLUMN_VALUE_DUPLICATE(3009, "COLUMN_VALUE_DUPLICATE", "重复"),
        CHECK_NEED_DETAIL_LIST(3010, "CHECK_NEED_DETAIL_LIST", "缺少明细"),
        CHECK_NEED_DETAIL_LIST_INFO(3011, "CHECK_NEED_DETAIL_LIST_INFO", "缺少明细信息"),
        CHECK_NUM_POSITIVE_INTEGER(3012, "CHECK_NUM_POSITIVE_INTEGER", "需要正整数"),
        CHECK_NUM_NON_NEGATIVE(3013, "CHECK_NUM_NON_NEGATIVE", "需要非负数"),

        // 登录相关
        VERIFY_CODE_GENERATE_FAILED(707, "VERIFY_CODE_GENERATE_FAILED", "验证码生成失败"),
        HANDEL_CODE_ERROR(708, "HANDEL_CODE_ERROR", "验证码校验失败"),
        LOGIN_CODE_INVALID(2007, "LOGIN_CODE_INVALID", "验证码错误"),
        LOGIN_CODE_EXPIRED(2008, "LOGIN_CODE_EXPIRED", "验证码已过期，请重新获取"),
        LOGIN_CODE_NEED(2009, "LOGIN_CODE_NEED", "缺少验证码"),
        USERNAME_PWD_ERROR(2010, "USERNAME_PWD_ERROR", "用户名或密码错误"),
        MOBILE_ERROR(2013, "MOBILE_ERROR", "手机号错误"),
        USER_INFO_REFRESHED(2011, "USER_INFO_REFRESHED", "用户信息已更新，当前操作无效，请刷新重试"),
        USER_INVALID(2012, "USER_INVALID", "账号已禁用"),
        UNKNOWN_USER(3004, "UNKNOWN_USER", "未知用户"),
        NEED_VERIFY_DATA(3005, "NEED_VERIFY_DATA", "缺少校验参数"),
        NEED_NEW_PASSWORD(3006, "NEED_NEW_PASSWORD", "缺少新密码"),
        NEED_MODIFIED_BY(3007, "NEED_MODIFIED_BY", "缺少更新人员"),
        HAS_USER_BIND_ROLE(3014, "HAS_USER_BIND_ROLE", "存在用户绑定当前角色"),

        // 数据迁移相关
        FILE_NAME_INVALID(3060, "FILE_NAME_INVALID", "模板文件名不合法"),

        // 存在子类未删除
        SUB_INFO_UN_DELETED_DIY(3100, "SUB_INFO_UNDELETED", ""),
        SUB_INFO_UN_DELETED(3101, "SUB_INFO_UNDELETED", "存在子类未删除"),

        // 消息相关
        MQ_SEND_NEED_RECEIVERS(665, "MQ_SEND_NEED_RECEIVERS", "缺少消息接收者"),
        MQ_SEND_FAIL(666, "MQ_SEND_FAIL", "消息推送失败"),
        NEED_INCREMENT_KEY(667, "NEED_INCREMENT_KEY", "自增标识不能为空"),
        FLOW_NO_GENERATE_FAIL(668, "FLOW_NO_GENERATE_FAIL", "流水号生成失败"),
        // 报表相关
        NEED_REPORT_ID(3017, "NEED_REPORT_ID", "缺少报表id"),
        NEED_REPORT_SQL(3018, "NEED_REPORT_SQL", "缺少报表查询语句"),
        REPORT_ID_INVALID(3019, "REPORT_ID_INVALID", "报表ID不是数字"),
        NEED_REPORT_SEARCH_TYPE(3020, "NEED_REPORT_TYPE", "缺少报表统计类型"),
        REPORT_TEMPLATE_NO_EXIST(3021, "REPORT_TEMPLATE_NO_EXIST", "该报表打印模板文件不存在"),
        REPORT_PRINT_ERROR(3022, "REPORT_PRINT_ERROR", "报表打印失败"),
        // 仪表相关
        NEED_CHART_ID(3017, "NEED_REPORT_ID", "缺少仪表id"),
        NEED_CHART_SQL(3018, "NEED_REPORT_SQL", "缺少仪表查询语句"),
        CHART_ID_INVALID(3019, "REPORT_ID_INVALID", "仪表ID不是数字"),
        NEED_CHART_SEARCH_TYPE(3020, "NEED_REPORT_TYPE", "缺少仪表统计类型"),

        // 字典相关
        DICT_ATTRIBUTE_GET_NONE(768, "DICT_ATTRIBUTE_GET_NONE", "字典未获取到，请检查是否配置"),
        DICT_ATTRIBUTE_DATA_ERROR(769, "DICT_ATTRIBUTE_DATA_ERROR", "字典数据格式配置有误"),

        //审核
        AUDIT_ERROR(16000,"AUDIT_ERROR","审核失败"),
        //打印
        PRESCRIPTION_UNKONW(17000, "PRESCRIPTION_UNKONW", "未知处方信息"),
        PRINT_ERROR(17001, "PRINT_ERROR", "生成打印文件错误"),

        OLD_PASSWORD_ERROR(18003,"OLD_PASSWORD_ERROR","原密码错误"),

        // 推送相关
        PUSH_UNKNOWN_USER_ID(80001, "PUSH_UNKNOWN_USER_ID", "缺少用户ID"),
        PUSH_MSG_NEED(80002, "PUSH_MSG_NEED", "缺少消息内容"),
        PUSH_UNKNOWN_REGISTRATION_ID(80003, "PUSH_UNKNOWN_REGISTRATION_ID", "缺少app注册ID"),
        PUSH_UNKNOWN_ROLE_CODE(80004, "PUSH_UNKNOWN_ROLE_CODE", "缺少角色标识"),
        PUSH_UNKNOWN_ROLE_ID(80005, "PUSH_UNKNOWN_ROLE_ID", "缺少角色ID"),
        PUSH_MSG_FAIL(80006, "PUSH_MSG_FAIL", "推送失败"),
        PUSH_ROLE_LIST_GET_FAIL(80007, "PUSH_ROLE_LIST_GET_FAIL", "角色列表获取失败"),
        PUSH_MSG_FAIL_SAVE_SUCCESS(80006, "PUSH_MSG_FAIL_SAVE_SUCCESS", "推送失败，消息已保存"),
        WECHAT_INVALID_CODE(80088, "WECHAT_INVALID_CODE", "无效code，无法获取到sessionKey和openid"),
        WECHAT_UNKNOW_SESSION_USER(60001, "WECHAT_UNKNOW_SESSION_USER", "未知登录用户"),

        ;


        CommonBusinessCode(int code, String codeStr, String msg) {
            this.code = code;
            this.codeStr = codeStr;
            this.msg = msg;
        }

        private int code;
        private String codeStr;
        private String msg;

        public int getCode() {
            return code;
        }

        public String getCodeStr() {
            return codeStr;
        }

        public String getMsg() {
            return msg;
        }
    }

    /**
     * 权限是否需要认证枚举
     */
    public enum AuthorizationEnum {
        /**
         * 认证类型
         */
        ANON("anon", "匿名"),
        AUTHC_TOKEN("authcToken", "认证");

        AuthorizationEnum(String key, String name) {
            this.key = key;
            this.name = name;
        }

        private String key;
        private String name;

        public String getKey() {
            return key;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 报表检索类型
     */
    public enum ReportSearchTypeEnum {
        /**
         * 报表检索类型
         */
        DATE("date", "日统计"),
        MONTH("month", "月统计"),
        YEAR("year", "年统计"),
        ;

        ReportSearchTypeEnum(String key, String name) {
            this.key = key;
            this.name = name;
        }

        private String key;
        private String name;

        public String getKey() {
            return key;
        }

        public String getName() {
            return name;
        }
    }


    /**
     * 消息类型
     */
    public enum NewsType {
        /**
         * 订单状态
         */
        UNDO(0, "代办"),
        NEWS(1, "消息"),
        NOTICE(2, "通知"),
        ;

        NewsType(int key, String name) {
            this.key = key;
            this.name = name;
        }

        private Integer key;
        private String name;

        public Integer getKey() {
            return key;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 消息接收范围
     */
    public enum NewsScope {
        /**
         * 消息接收范围
         */
        GLOBAL(0, "全局"),
        ROLE(1, "角色"),
        SINGLE(2, "个人"),
        ;

        NewsScope(int key, String name) {
            this.key = key;
            this.name = name;
        }

        private Integer key;
        private String name;

        public Integer getKey() {
            return key;
        }

        public String getName() {
            return name;
        }
    }

    /**
     * 消息标签
     */
    public enum NewsTag {
        /**
         * 消息标签
         */
        SUCCESS("success", "代办"),
        INFO("info", "提示"),
        WARNING("warning", "警告"),
        ERROR("error", "错误"),
        ;

        NewsTag(String key, String name) {
            this.key = key;
            this.name = name;
        }

        private String key;
        private String name;

        public String getKey() {
            return key;
        }

        public String getName() {
            return name;
        }
    }
    /**
     * 打印类型枚举
     */
    public enum PrintType {
        /**
         * 文件类型
         */
        PRINTEXCEL("1", "解析excel模板打印"),
        PRINTWORD("2", "解析word模板打印"),
        ;
        private String type;
        private String name;

        PrintType(String type, String name) {
            this.type = type;
            this.name = name;
        }

        public String getType() {
            return type;
        }

        public String getName() {
            return name;
        }
    }
}
